package com.zju.DoctorGo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zju.DoctorGo.dto.ScheduleFilterDTO;
import com.zju.DoctorGo.entity.Schedule;
import com.zju.DoctorGo.mapper.ScheduleMapper;
import com.zju.DoctorGo.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class ScheduleServiceImpl extends ServiceImpl<ScheduleMapper, Schedule> implements ScheduleService {

        @Autowired
        private ScheduleMapper scheduleMapper;

        @Override
        public List<Schedule> getSchedules(ScheduleFilterDTO filter) {
            return scheduleMapper.selectByFilter(filter);
        }

        @Override
        @Transactional
        public void addSchedule(Schedule schedule) {
            scheduleMapper.insert(schedule);
        }

        @Override
        @Transactional
        public void deleteSchedules(ScheduleFilterDTO filter) {
            scheduleMapper.deleteByFilter(filter);
        }

        @Override
        @Transactional
        public void updateSchedule(Schedule schedule) { scheduleMapper.updateById(schedule); }
}
